import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default ({
    state: {
        menuList: [
            {
                "id": 1,
                "title": "系统管理",
                "icon": "el-icon-s-operation",
                "path": "",
                "name": "sys:manage",
                "component": "",
                "children": [
                    {
                        "id": 2,
                        "title": "用户管理",
                        "icon": "el-icon-s-custom",
                        "path": "/sys/users",
                        "name": "sys:user",
                        "component": "sys/User"
                    },
                    {
                        "id": 3,
                        "title": "客家语音管理",
                        "icon": "el-icon-rank",
                        "path": "/sys/audio",
                        "name": "sys:audio",
                        "component": "sys/Audio"
                    },
                    {
                        "id": 4,
                        "title": "论文管理",
                        "icon": "el-icon-notebook-2",
                        "path": "/sys/thesis",
                        "name": "sys:thesis",
                        "component": "sys/Thesis"
                    }
                ]
            },
            {
                "id": 5,
                "title": "系统工具",
                "icon": "el-icon-s-tools",
                "path": "",
                "name": "sys:tools",
                "component": null,
                "children": [
                    {
                        "id": 6,
                        "title": "数字字典",
                        "icon": "el-icon-s-order",
                        "path": "/sys/dicts",
                        "name": "sys:dict",
                        "component": "sys/Dict"
                    }
                ]
            }
        ],
        /*默认标签页*/
        editableTabsValue: 'Main',
        /*起始只有首页*/
        editableTabs: [
            {
                title: '首页',
                name: 'Main'
            }
        ]
    },
    getters: {
    },
    mutations: {
        /*setMenuList(state, menus) {
            state.menuList = menus;
        },
        setPermList(state, perms) {
            state.permList = perms;
        },
        /!*更新是否存在路由  1存在， 0不存在*!/
        changeRouteStatus(state, hasRoute) {
            state.hasRoute = hasRoute;
        },*/
        addTab(state, tab) {
            //判断是否已经被点击过
            let index = state.editableTabs.findIndex(e => e.name === tab.name)
            if (index === -1) {
                state.editableTabs.push({
                    title: tab.title,
                    name: tab.name
                });
            }
            state.editableTabsValue = tab.name;
        }/*,
        resetState: (state) => {
            state.menuList = []
            state.permList = []
            state.hasRoute = "0"
            state.editableTabsValue = 'Main'
            state.editableTabs = [{
                title: '首页',
                name: 'Main'
            }]
        }*/

    },
    actions: {
    },
    modules: {
    }
})
